package com.letsiot.applications.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import com.letsiot.applications.entity.SysMessage;
import com.letsiot.applications.repository.SysMessageMapper;
import com.letsiot.applications.service.SysMessageService;

@Service
public class SysMessageServiceImpl implements SysMessageService {

    @Autowired
    private SysMessageMapper sysMessageMapper;

    @Override
    public int save(SysMessage entity) {
        return sysMessageMapper.insertSelective(entity);
    }

    @Override
    public int delete(Long id) {
        return sysMessageMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int update(SysMessage entity) {
        return sysMessageMapper.updateByPrimaryKeySelective(entity);
    }

    @Override
    public SysMessage findById(Long id) {
        return sysMessageMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<SysMessage> getAll() {
        return null;
    }

    @Override
    public Page<SysMessage> listMessage(SysMessage query, Pageable pageable) {
        return sysMessageMapper.listMessage(query, pageable);
    }

    @Override
    public int countByMessageTypeAndModule(String messageType, String moduleCode, String isread) {
        return sysMessageMapper.countByMessageTypeAndModule(messageType, moduleCode, isread);
    }

    @Override
    public SysMessage findWarningMessageCode(String messageCode) {
        return sysMessageMapper.findWarningMessageCode(messageCode);
    }
}
